<?php
namespace GK;
use GK\Route\Driver;
class Route extends App
{
    //路由模式
    protected static $RouteDriver=[
            '0'=>'Path_Info',
            '1'=>'Domain_Info',
        ];
    /**
     * 路由模块启动
     */
    public static function Register(){
        if(self::$Config['RouteConfig']['url_route_on']===false||self::$Config['RouteConfig']['url_route_type']=='0'){
            self::$Config['RouteConfig']['url_route_type']='0';
        }
        $RouteDriver='\\GK\Route\Driver\\'.self::$RouteDriver[self::$Config['RouteConfig']['url_route_type']];
        $RouteDriver=new $RouteDriver();
        self::TrRoute($RouteDriver->CheckRoute(self::$Config));
    }
    /**
     * 路由匹配数据转换
     */
    public static function TrRoute($RouteData=null){
        if(empty($RouteData)){
            self::Bin();
        }else{
            foreach(array_keys($RouteData) as $key => $value) {
                self::$$value=$RouteData[$value];
            }
            self::Bin();
        }
    }
    //路由初始化绑定
    public static function Bin($Value=null){
        if(empty($Value)){
            if(empty(self::$Module)){
                self::$Module=self::$Config['default_module'];
            }
            if(empty(self::$Controller)){
                self::$Controller=self::$Config['default_controller'];
            }
            if(empty(self::$Action)){
                self::$Action=self::$Config['default_action'];
            }
        }else{
            $Value=ucwords($Value);
            self::$$Value=self::$Config['default_'.strtolower($Value)];
        }
    }
}